package com.netposa.task;

import com.netposa.config.ImportPoliceConfig;
import com.netposa.service.PoliceImportService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.config.ScheduledTask;
import org.springframework.stereotype.Component;

@Component
public class PoliceImportTask {
   private static Logger logger = Logger.getLogger(ScheduledTask.class);
   @Autowired
   private PoliceImportService policeImportService;
   @Autowired
   private ImportPoliceConfig config;

   @Scheduled(
      fixedDelayString = "${police.import.interval}"
   )
   public void fugitiveTask() {
      if (this.config.getOpen()) {
         this.policeImportService.importPolice();
      } else {
         logger.info("警情导入开关未开启!");
      }

   }
}
